package bishizhuanyong.欧科云链;

import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums=new int[n];
        for (int i=0;i<nums.length;i++)
            nums[i]=sc.nextInt();
        if (n==1){
            System.out.println(nums[0]);
            return;
        }
        int[] dpa=new int[n+1];
        dpa[1]=nums[0];
        for (int i=2;i<dpa.length-1;i++){
            dpa[i]=Math.max(dpa[i-1],dpa[i-2]+ nums[i-1]);
        }
        int res1=dpa[dpa.length-2];
        int[] dpb=new int[n+1];
        dpb[1]=0;
        for (int i=2;i< dpb.length;i++)
            dpb[i]=Math.max(dpb[i-1],dpb[i-2]+nums[i-1]);
        int res2=dpb[dpb.length-1];
        System.out.println(Math.max(res1,res2));
    }
}
